
if( typeof (model) == 'undefined')
	model = {}
if( typeof (model.user) == 'undefined')
	model.user = {}

function User(options){
	var settings = $.extend({
		user : {}
	}, options || {});
	
	var self = this;
	
	self.username = ko.observable(settings.user.username);
	self.password = ko.observable(settings.user.password);
	self.repsw = ko.observable(); //第二次输入密码
	
	self.login = function(){
		
		var name = $.trim(self.username());
		var psw = $.trim(self.password());
		if(null == name ||"" == name || null == psw || "" == psw){
			return false;
		}
		
		var params = {'user.username' : name, 'user.password' : psw};
		var result = {};
		$.getJSON('submit-login.action',$.param(params), function(json){
			result.success = json.success;
			result.pid = json.pid;
		});
		
		return result;
	};
	
	return this;
}

model.user.initializeViewModel = function(options) {
	return  new User(options);
}